package com.cloudcc.mobile.util;

import com.cloudcc.cloudframe.model.MenuModel;
import com.cloudcc.cloudframe.model.MenuTabModel;
import com.cloudcc.cloudframe.util.StringUtils;
import com.cloudcc.mobile.AppContext;
import com.cloudcc.mobile.entity.Module;
import com.cloudcc.mobile.entity.Tabs;

public class UrlTools {

	// 版本升级网址
	// public static String
	// updateUrl="http://www.cloudcc.com/edm-zh/mobileAppUpdate.xml";
	public static String updateUrl = "http://yalitest.cloudcc.cn/mobileAppUpdate.xml";
	// public static String
	// updateUrl="http://yalitest.cloudcc.cn/mobileAppUpdate_test.xml";
	// user图片的路径
	public static String UserImageUrl = "/sdcard/CloudCC/WeiXin/";
	// 登陆的url
	public static String loginurl = "https://login.cloudcc.com/weixinlogin.action?loginnum=logout";
	// 登陆后菜单页

	// public static String weixinUrl="https://app1.cloudcc.com";
	// public static String weixinUrl="http://test.cloudcc.cn";
	public static String weixinUrl = "http://ccws.cloudcc.com";
	public static String menuurl = "/WeiXin_index.action";
	public static String loginWeb = "/home_mainPage.action";
	public static String menuurl2 = "/main.action?rtnURL=%2FWeiXin_index.action";

	public static String getimageurl = "/chatterfile.action?m=preview&fileid=";
	/**
	 * 软件模块网址
	 */
	public static String ApprovalUrl = "/WeiXin_getmangeAllAppRequest.action";// 待审批
	public static String EventUrl = "/wx_taskquery.action?m=list&objid=event&eventcondition=today";// 任务界面
	public static String TaskUrl = "/wx_taskquery.action?m=list&objid=task&taskcondition=today";// 事件

	public static String AddEvent = "/wx_taskquery.action?m=newpage&obj=bef&rtnURL=%2Fwx_taskquery.action%3Fobjid%3Devent%26eventcondition%3Dtoday%26m%3Dlist";
	public static String AddTask = "/wx_taskquery.action?m=newpage&obj=bfa&rtnURL=%2Fwx_taskquery.action%3Fobjid%3Dtask%26taskcondition%3Dtoday%26m%3Dlist";
	// 返回的按钮
	public static String FanhuiTask = "/wx_taskquery.action?objid=task&taskcondition=today&m=list&rtnURL=";
	public static String FanhuiEvent = "/wx_taskquery.action?objid=event&eventcondition=today&m=list&rtnURL=";

	public static String wxIndexUrl = "/WeiXin_index.action";
	public static String ModuleUrl = "/WeiXin_getUserTabList.action?appId=";

	public static String getModuleUrl(String appId, String appName) {
		return ModuleUrl + appId;
		// return ModuleUrl+appId+"&appName="+appName;
	}

	// 选项卡获取网址
	public static String getTabsUrl(Tabs tab, Module module) {
		String URL = tab.getUrl();
		String returnurl = "&rtnURL=WeiXin_getUserTabList.action?appId="
				+ module.getId();
		String returnurl2 = "?rtnURL=WeiXin_getUserTabList.action?appId="
				+ module.getId() + "&appName=" + module.getLabel();
		if (URL.contains("/query.action")) {
			String url = URL.substring(URL.lastIndexOf("=") + 1, URL.length());
			return "/wx_lookAtRecent.action?obj=" + url + "&m=wx_lookAtRecent"
					+ returnurl;
		} else if (URL.contains("/controller.action")) {
			String url = URL.substring(1, URL.length());
			return "/weixin" + url;
		} else if (URL.contains("/viewDashboard.action")) {
			// weiviewDashboard.action
			String url = URL.substring(1, URL.length());
			return "/wei" + url;
		} else if (URL.contains("/reportList.action")) {
			return "/weixinreportlist.action" + returnurl2;
			// return "/weixinreportlist.action";
		} else {
			return "";
		}
	}

	// 选项卡获取网址
	public static String getTabsUrl(MenuTabModel tab, MenuModel module) {
		String URL = tab.url;
		String returnurl = "&rtnURL=WeiXin_getUserTabList.action?appId="
				+ module.id;
		String returnurl2 = "?rtnURL=WeiXin_getUserTabList.action?appId="
				+ module.id + "&appName=" + module.label;
		
	   if (StringUtils.contains(URL,"/query.action?obj=rep")) {
			return "/weiWorkReport.action?m=list&queryTab=1&rtnURL=WeiXinindex.action";
		}else if (URL.contains("/query.action")) {
			String url = URL.substring(URL.lastIndexOf("=") + 1, URL.length());
			return "/wx_lookAtRecent.action?obj=" + url + "&m=wx_lookAtRecent"
					+ returnurl;
		} else if (URL.contains("/controller.action")) {
			String url = URL.substring(1, URL.length());
			return "/weixin" + url;
		} else if (URL.contains("/viewDashboard.action")) {
			// weiviewDashboard.action
			String url = URL.substring(1, URL.length());
			return "/wei" + url + returnurl2;
		} else if (URL.contains("/reportList.action")) {
			return "/weixinreportlist.action" + returnurl2;
			// return "/weixinreportlist.action";
		} else if (StringUtils.contains(URL,"salesCloudDashboard.action?m=query")) {
			return "/weisalesCloudDashboard.action?m=query";
		}  else {
			return "";
		}
	}

	// 获取客户，联系人，等等详情网址
	public static String getObjectUrl(String id) {
		// return "/wx_taskquery.action?m=query&id="+id;周为龙写的
		return "/weiquery.action?m=query&id=" + id;
	}

	// 任务 时间 详情网址
	public static String getTaskOrEventUrl(String id) {
		// return "wx_taskquery.action?m=query&id="+id;周为龙写的
		return "wx_taskquery.action?m=query&id=" + id;
	}

	// 获取快速添加的方法 //urlmana
	public static String getMenuAddUrl(Tabs tab) {
		String URL = tab.getUrl();
		String url = URL.substring(URL.lastIndexOf("=") + 1, URL.length());
		return "/weiquery.action?obj="
				+ url
				+ "&m=newpage&rtnURL=%2Fwx_lookAtRecent.action%3Fm%3Dwx_lookAtRecent%26obj%3D"
				+ url;
	}

	public static String getFanhuiUrl(String obj) {
		return "/wx_lookAtRecent.action?m=wx_lookAtRecent&obj=" + obj;
	}

	/**
	 * 后台登陆
	 */
	// url
	// public static String url="https://app1.cloudcc.com/";
	public static String url = "http://ccws.cloudcc.com/";
	// http://test.cloudcc.cn/bindinglogin.action?binding=17B94D28869745696B25E2922A160961
	// public static String url="http://test.cloudcc.cn/";
	// public static String url="http://zstest.cloudcc.cn/";
	// public static String url="http://211.151.201.29:9002/";
	// 登陆path
	public static String loginpath = "distributor.action?serviceName=clogin&";
	public static String loginpath2 = "distributor.action";
	// 图片查看url
	public static String imgurl_path = "http://applib.cloudcc.cn/querysome.action?m=viewImg&fileid=";
	// chat内容图查看网址
	public static String imgurlsee = "querysome.action?m=viewImg&fileid=";
	// chater内容文件下载地址
	public static String wenjianurl = "distributor.action?serviceName=downloadFileChatter&fileId=";

	// chat用户头像查看
	public static String getTopImage(String topimg) {
		String topimage = url
				+ "distributor.action?serviceName=showChatterImage&type=user&id="
				+ topimg + "&binding=" + AppContext.binding;
		return topimage;
	}

	// 图片上传url
	// public static String
	// imgupload_path=url+"distributor.action?serviceName=uploadImg&data=";
	// public static String
	// imgupload_path=url+"distributor.action?serviceName=uploadImgMany&data=";
	public static String imgupload_path = "distributor.action?serviceName=uploadImgMany&data=";
	// urlpath
	public static String url_path = "distributor.action?";
	public static String postpath = "distributor.action";

}
